import { getAreaObj } from '@/utils/util'
import {configToSearch,toSearchHandle} from '@/views/datacenter/business/utils/index'

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属区域',
			prop: 'belongAreaName',
		},
		// { label: '统一社会信用代码', prop: 'creditCode' },
		{ label: '机构名称', prop: 'organizationName' },
		{ label: '联系人', prop: 'contacts' },
		{ label: '联系方式', prop: 'contactsPhone',plusXing: '5,2' },
		{
			label: '原等级',
			prop: 'orgRawLevel',
			propName:'orgRawLevelLabel',
			code:'ORG_LEVEL',
			api:'getDictItemList',
			type:'remoteSelect'
		},
		{
			label: '现等级',
			prop: 'orgPresentLevel',
			propName:'orgPresentLevelLabel',
			code:'ORG_LEVEL',
			api:'getDictItemList',
			type:'remoteSelect'
		},
		{ label: '申请金额', prop: 'subsidyTotalAmount' },
		{ label: '区民政审批时间', prop: 'civilAdministrationAuditTime' },
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共2个：',
					children: [
						{
							label: '《等级提升补贴信息表》',
							link: true,
							url: 'dpLevelPromotionSubsidy_downloadTemplate',
						},
						{
							label: '《等级提升补贴-老人花名册》',
							link: true,
							url: 'view_dpLevelPromotionSubsidyServiceObject_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入《等级提升补贴信息表》',
			description: '',
			uploadTip: '等级提升补贴信息表',
			active: 2,
			url: 'dpLevelPromotionSubsidy_import',
			code: 2017,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的等级提升补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《等级提升补贴-老人花名册》',
			description: '',
			uploadTip: '等级提升补贴-老人花名册表',
			active: 2,
			url: 'view_dpLevelPromotionSubsidyServiceObject_import',
			code: 2027,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的等级提升补贴-老人花名册信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}
export const detailConfig: any = {
	
	prop: 'base1',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		// 申请人信息
		{
			type: 'DividerHtml',
			modelValue: '基本信息',
			span: 24,
		},
		{
			label: '机构名称',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '机构统一信用代码',
			prop: 'creditCode',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '法定代表人',
			prop: 'legalPersonName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '所属区划',
			prop: 'areas_name',
			type:'AplidAreaSelect',
			span: 8,
		},
		{
			label: '机构地址',
			prop: 'organizationAddress',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '邮政编号',
			prop: 'postalCode',
			type: 'text',
			maxlength: '6',
			showWordLimit: true,
			span:8
		},
		{
			label: '联系人',
			prop: 'contacts',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '联系电话',
			prop: 'contactsPhone',
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '营业执照(民非)证号',
			prop: 'businessLicense',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '机构设置证号(备案)',
			prop: 'organizationFilings',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '开户银行',
			prop: 'openingBank',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '银行账号',
			prop: 'bankAccount',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		//申请内容
		{
			type: 'DividerHtml',
			modelValue: '申请内容',
			span: 24,
		},
		{
			label: '机构原等级',
			prop: 'orgRawLevel',
			propName:'orgRawLevelLabel',
			code:'ORG_LEVEL',
			api:'getDictItemList',
			type:'remoteSelect',
			span: 8,
		},
		{
			label: '机构原等级授予时间',
			prop: 'rawLevelAwardTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '机构现等级',
			prop: 'orgPresentLevel',
			propName:'orgPresentLevelLabel',
			code:'ORG_LEVEL',
			api:'getDictItemList',
			type:'remoteSelect',
			span: 8,
		},
		{
			label: '机构现等级授予时间',
			prop: 'presentLevelWaardTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '核定床位数',
			prop: 'checkBed',
			type:'text',
			append:'张',
			span: 8,
		},
		{
			label: '入住人员数',
			prop: 'checkInStaff',
			type:'text',
			append:'人',
			span: 8,
		},
		{
			label: '养老机构率',
			prop: 'organizationRate',
			type:'text',
			append:'百分比',
			span: 8,
		},
		{
			label: '申报经费',
			prop: 'declareExpenditure',
			type:'text',
			append:'元',
			span: 8,
		},
		// 审核意见
		{
			type: 'DividerHtml',
			modelValue: '审核意见',
			span: 24,
		},
		{
			label: '单位审核意见',
			prop: 'unitAuditOpinion',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '单位审核时间',
			prop: 'unitAuditTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '区民政审核意见',
			prop: 'civilAdministrationOpinion',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '区民政审核时间',
			prop: 'civilAdministrationAuditTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '补贴总金额',
			prop: 'subsidyTotalAmount',
			type:'text',
			append:'元',
			span: 8,
		},
		{
			label: '补贴发放时间',
			prop: 'subsidyGrantTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
	],
}

const moreSearchConfig:any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column:[
		...configToSearch(detailConfig.column)
	]
}
export const baseConfig: any = {
	pageName: '等级提升补贴',
	dictcodes: ['ORG_LEVEL','NURSE_TYPE','ABILITY_LEVEL_CITY_STANDARD','ELDERLY_RELATIONSHIP'],
	rowKey: 'id',
	tipLabel: 'organizationName',
	// exportMqTopic: '/ning/export',
	exportMqTopic: [
		{
			topic: '/ning/export/dpLevelPromotionSubsidy/',
			label: '等级提升补贴信息',
			code: 2017,
			po: 'dpLevelPromotionSubsidyPO',
		},
		{
			topic: '/ning/export/dpLevelPromotionSubsidyServiceObject/',
			label: '等级提升补贴-老人花名册',
			code: 2027,
			po: 'dpLevelPromotionSubsidyServiceObjectPO',
		},
	],
	api: {
		moreSearch:'view_dpLevelPromotionSubsidy_search',
		index: 'dpLevelPromotionSubsidy_page',
		delete: 'dpLevelPromotionSubsidy_del',
		export: 'view_dpLevelPromotionSubsidy_exportAll',
		import: 'dpLevelPromotionSubsidy_import',
	},
	auth: {
		index: 'view_dpLevelPromotionSubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpLevelPromotionSubsidy_del',
		// export: 'view_dpLevelPromotionSubsidy_exportAll',
		// import: 'view_dpLevelPromotionSubsidy_import',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'Detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '信用代码',
				prop: 'creditCode',
				type: 'input',
				span: 6,
			},
			{
				label: '机构名称',
				prop: 'organizationName',
				type: 'input',
				span: 6,
			},
			{
				label: '联系方式',
				prop: 'contactsPhone',
				type: 'input',
				span: 6,
			},
			{
				label: '所属地区',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '联系人',
				prop: 'contacts',
				type: 'input',
				span: 6,
			},

			// todao
			{
				label: '区民政审批时间',
				prop: 'civilAdminTimeBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	moreSearchConfig,
	detailConfig,
	tableConfig,
	importConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig,{},params)
		if (params.civilAdminTimeBetween) {
			params.civilAdminTimeBetween = params.civilAdminTimeBetween.join(',')
		}
		let areasObj = getAreaObj(params.areas_name, 'belong')
		let crAreasName = getAreaObj(params.cr_areas_name,'cr')
		return Promise.resolve({
			...params,
			...areasObj,
			...crAreasName,
			areas_name: undefined,
			cr_areas_name:undefined
		})
	},
	onLoadFormate: async (arr) => {
		console.log('参数二', arr)
		const tableData = arr.map((item) => {
			const areas_name = getAreaObj(item, 'belong')
			const cr_areas_name = getAreaObj(item,'cr')
			return {
				...item,
				areas_name,
				cr_areas_name
			}
		})
		return Promise.resolve(Object.freeze(tableData))
	},
}
